package com.autobole.bldj.config.system;

import liquibase.integration.spring.SpringLiquibase;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;


/**
 * @author ：lzp
 * @date ：Created in 2019/1/24 10:40
 * @description：数据库相关
 * @modified By：
 * @version: 1$
 */
@Configuration
@EnableConfigurationProperties(LiquibaseProperties.class)
public class DataSourceConfig {

    @Bean
    public SpringLiquibase liquibase(DataSource dataSource, LiquibaseProperties liquibaseProperties) throws Exception {
        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setDataSource(dataSource);
        liquibase.setChangeLog(liquibaseProperties.getChangeLog());
        liquibase.setShouldRun(liquibaseProperties.isEnabled());
        //liquibase.setDropFirst(liquibaseProperties.isDropFirst());
        return liquibase;
    }
}